package com.myapp.api.service.impl;

import com.myapp.api.entity.Major;
import com.myapp.api.mapper.MajorMapper;
import com.myapp.api.service.MajorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MajorServiceImpl implements MajorService {
    @Autowired
    private MajorMapper mapper;

    @Override
    public List<Major> getMajors() {
        return mapper.getMajors();
    }

    @Override
    public Major getMajorById(@Param("id") Integer id) {
        return mapper.selectByPrimaryKey(id);
    }

    @Override
    public Major getMajorbyMid(@Param("mid") String mid) {
        return mapper.getMajorByMid(mid);
    }

    @Override
    public Integer getMajorbyOneMid(@Param("mid") String mid) {
        return mapper.getMajorByOneMid(mid);
    }

    @Override
    public List<Major> getMajorByMname(@Param("mname") String mname) {
        return mapper.getMajorByMname(mname);
    }

    @Override
    public int addMajor(@Param("record") Major record) {
        return mapper.insertSelective(record);
    }

    @Override
    public int deleteMajorById(@Param("id") Integer id) {
        return mapper.deleteByPrimaryKey(id);
    }

    @Override
    public int putMajor(@Param("record") Major record) {
        return mapper.updateByPrimaryKeySelective(record);
    }
}
